package cn.nexd.map.location.collector.core;

import android.content.Context;
import android.hardware.Sensor;

import cn.nexd.map.location.collector.BasebandCollector;
import cn.nexd.map.location.collector.BluetoothCollector;
import cn.nexd.map.location.collector.CollectorConfig;
import cn.nexd.map.location.collector.SensorCollector;
import cn.nexd.map.location.collector.WifiCollector;
import cn.nexd.map.location.collector.listener.BasebandCollectorResultListener;
import cn.nexd.map.location.collector.listener.BluetoothCollrctorResultListener;
import cn.nexd.map.location.collector.listener.SensorCollectorResultListener;
import cn.nexd.map.location.collector.listener.WifiCollectorResultListener;


/**
 * CollectorTaskFactory create by codingfish at 15/5/4
 * TODO:
 *
 * @Version V1.0
 */
public final class CollectorTaskFactory {

    public static WifiCollector getWifiCollectorTask(Context context, WifiCollectorResultListener wifiCollectorResultListener, CollectorConfig collectorConfig) {

        return new WifiCollectorTask(context, wifiCollectorResultListener, collectorConfig);
    }

    public static BluetoothCollector getBluetoothCollectorTask(Context context, BluetoothCollrctorResultListener bluetoothCollrctorResultListener, CollectorConfig collectorConfig) {
        return new BluetoothCollectorTask(context, bluetoothCollrctorResultListener, collectorConfig);
    }

    public static BasebandCollector getBasebandCollectorTask(Context context, BasebandCollectorResultListener basebandCollectorResultListener, CollectorConfig collectorConfig) {
        return new BasebandCollectorTask(context, collectorConfig, basebandCollectorResultListener);
    }

    public static SensorCollector getSensorCollectorTask(int sensorType, Context context, SensorCollectorResultListener sensorCollectorResultListener, CollectorConfig collectorConfig) {
        SensorCollector sensorCollector = null;
        switch (sensorType) {
            case Sensor.TYPE_ACCELEROMETER:
                sensorCollector = new AccelerometerSensorCollectorTask(context, sensorCollectorResultListener, collectorConfig);
                break;
            case Sensor.TYPE_STEP_COUNTER:
                sensorCollector = new StepCounterCollectorTask(context, sensorCollectorResultListener, collectorConfig);
                break;
            case Sensor.TYPE_GRAVITY:
                sensorCollector = new GravitySensorCollectorTask(context, sensorCollectorResultListener, collectorConfig);
                break;
            case Sensor.TYPE_GYROSCOPE:
                sensorCollector = new GyroscopeCollectorTask(context, sensorCollectorResultListener, collectorConfig);
                break;
            case Sensor.TYPE_LINEAR_ACCELERATION:
                sensorCollector = new LinearAccelerationCollectorTask(context, sensorCollectorResultListener, collectorConfig);
                break;
            case Sensor.TYPE_MAGNETIC_FIELD:
                sensorCollector = new MagneticFileldCollectorTask(context, sensorCollectorResultListener, collectorConfig);
                break;
            case Sensor.TYPE_ORIENTATION:
                sensorCollector = new OrientationCollectorTask(context, sensorCollectorResultListener, collectorConfig);
                break;
            case Sensor.TYPE_ROTATION_VECTOR:
                sensorCollector = new RotationVectorCollectorTask(context, sensorCollectorResultListener, collectorConfig);
                break;
            case Sensor.TYPE_STEP_DETECTOR:
                sensorCollector = new StepDetectorCollectorTask(context, sensorCollectorResultListener, collectorConfig);
                break;
            default:
                android.util.Log.e("SensorTaskFactory", "不支持的传感器类型！");
                break;
        }
        return sensorCollector;
    }
}
